/*
 * Product 对象
 * @Author: chiangbt@geoportal.cn 
 * @Date: 2019-05-07 12:56:29 
 * @Last Modified by: chiangbt@geoportal.cn
 * @Last Modified time: 2019-05-19 01:43:37
 */
const mongoose = require('mongoose')
const uniqueValidator = require('mongoose-unique-validator');

const productSchema = new mongoose.Schema({
    _id: mongoose.Schema.Types.ObjectId,
    name: {
        type: String,
        required: true,
        unique: true
    },
    price: {
        type: Number,
        required: true
    }
}, {
    versionKey: false,
    timestamps: {
        createdAt: 'createdAt',
        updatedAt: 'updatedAt'
    }
})

productSchema.plugin(uniqueValidator);
module.exports = mongoose.model('Product', productSchema);